// 获取设备信息
export const getSystemInfo = () => {
  const system = uni.getWindowInfo()
  return {
    screenWidth: system.screenWidth, // 屏幕宽度
    screenHeight: system.screenHeight, // 屏幕高度
    pixelRatio: system.pixelRatio, // 像素比
    statusBarHeight: system.statusBarHeight, // 状态栏高度
    safeAreaInsets: system.safeAreaInsets, // 安全区域
  }
}

// 获取小程序右上角菜单信息
export const getMenuButtonBoundingClientRect = (): UniNamespace.GetMenuButtonBoundingClientRectRes => {
  // #ifndef H5
  return uni.getMenuButtonBoundingClientRect()
  // #endif
  return {
    width: 0,
    right: 0,
    height: 0,
    left: window.screen.width,
    top: 0,
    bottom: 0,
  }
}
/**
 * 获取导航栏高度
 * @param rectTop 小程序右上角菜单按钮的顶部位置
 * @param statusBarHeight  状态栏高度
 * @param rectHeight 小程序右上角菜单按钮的高度
 * @returns 返回计算后的导航栏高度
 */

// 计算状态栏高度
export const getNavigationBarHeight = (rectTop: number, statusBarHeight: number, rectHeight: number): number => {
  // #ifdef H5
  return 44
  // #endif
  // #ifdef MP-WEIXIN || MP-ALIPAY
  const navheight = rectHeight + (rectTop - (statusBarHeight || 0)) * 2
  return navheight + (statusBarHeight || 0)
  // #endif
}
